const a = function (
  _01,
  _02,
  { params = {} },
  { dc: { open, setModal, ...l } }
) {
  const transfer = params;
  const layout = { id: "1788812530857660417" };
  const modal = {
    title: "新增审核",
    width: "75vw",
    minHeight: document.body.clientHeight * 0.7,
    defaultFullscreen: false,
    destroyOnClose: true,
    maskClosable: false,
    centered: true,
    open: true,
    showOkBtn: false,
    showCancelBtn: true,
    cancelText: "退出",
  };
  const inner = {
    onOk: async function (
      a,
      { memory, ...b },
      { xe: { get }, dc: { http, message, reload, ...c }, ...d }
    ) {
      const checkList = [
        ...get(memory, "checkListBonus", []),
        ...get(memory, "checkListBx", []),
      ];


      if (!checkList.length) return message.info("请至少选择一条数据");
      setModal({ confirmLoading: true });
      try {
        const errorList = [];
        function toUp(str) {
          let newStr = "";
          let arr = str.split("_");
          arr.forEach((item, index) => {
            if (index > 0) {
              return (newStr += item.replace(item[0], item[0].toUpperCase()));
            } else {
              return (newStr += item);
            }
          });
          return newStr;
        }
        for (const item of checkList) {
          const params = {};
          Object.keys(item).forEach((key) => {
            params[toUp(key)] = item[key];
          });
          const res = await http.post(
            {
              url: "/ypxy/transfer/submit",
              data: { ...params, id: undefined },
            },
            { isTransformResponse: false }
          );
          if (res.code !== 200) {
            errorList.push(params.programName);
          }
        }
        if (errorList.length) {
          message.error(`项目${errorList.join(",")}审核失败`);
        } else {
          message.success("提交审核成功");
        }
        setModal({ confirmLoading: false });
        if (errorList.length !== checkList.length) {
          console.log(123123, c.update);

          c.update({
            path: "1788814383779532802",
            action: "load",
          });
          c.update({
            path: 1788814383779532802,
            action: "load",
          });
        }
      } catch (error) {
        setModal({ confirmLoading: false });
      }
    },
  };
  open({ inner, layout, modal, transfer });
};

const a1 = function (
  _01,
  _02,
  { params = {} },
  { dc: { open, reload, setModal, close } }
) {
  const transfer = params;
  const layout = { id: "1788812530857660417" };
  const modal = {
    title: "新增审核",
    width: "75vw",
    minHeight: document.body.clientHeight * 0.7,
    defaultFullscreen: false,
    destroyOnClose: true,
    maskClosable: false,
    centered: true,
    open: true,
    showOkBtn: true,
    showCancelBtn: true,
    cancelText: "退出",
  };
  const inner = {
    onOk: async function (
      _,
      { memory },
      { xe: { get }, dc: { http, message } }
    ) {
      const checkList = [
        ...get(memory, "checkListBonus", []),
        ...get(memory, "checkListBx", []),
      ];
      if (!checkList.length) return message.info("请至少选择一条数据");
      setModal({ confirmLoading: true });
      try {
        const errorList = [];
        function toUp(str) {
          let newStr = "";
          let arr = str.split("_");
          arr.forEach((item, index) => {
            if (index > 0) {
              return (newStr += item.replace(item[0], item[0].toUpperCase()));
            } else {
              return (newStr += item);
            }
          });
          return newStr;
        }
        for (const item of checkList) {
          const params = {};
          Object.keys(item).forEach((key) => {
            params[toUp(key)] = item[key];
          });
          const res = await http.post(
            {
              url: "/ypxy/transfer/submit",
              data: { ...params, id: undefined },
            },
            { isTransformResponse: false }
          );
          if (res.code !== 200) {
            errorList.push(params.programName);
          }
        }
        if (errorList.length) {
          message.error(`项目${errorList.join(",")}审核失败`);
        } else {
          message.success("提交审核成功");
        }
        setModal({ confirmLoading: false });
        close();
        if (errorList.length !== checkList.length) {
          reload();
        }
      } catch (error) {
        setModal({ confirmLoading: false });
      }
    },
  };
  open({ inner, layout, modal, transfer });
};

const c = async function (
  event,
  { $grid },
  { params = {}, memory, origin },
  { dc: { open, setModal }, xe: { get } }
) {
  const ret = await new Promise((resolve) => {
    const transfer = params;
    const layout = { id: "1785946370247495682" };
    const modal = {
      title: "添加项目",
      width: "55vw",
      height: document.body.clientHeight * 0.55,
      defaultFullscreen: false,
      destroyOnClose: false,
      maskClosable: false,
      open: true,
      showOkBtn: false,
      showCancelBtn: true,
      afterClose: function () {
        const ret = get(memory, "modal", false);
        delete memory.modal;
        resolve(ret);
      },
    };
    const inner = {};
    console.log("inner click: ", $grid, origin, memory, params, {
      inner,
      layout,
      modal,
      transfer,
    });
    open({ inner, layout, modal, transfer });
  });
  console.log("modal ret: ", ret);
  if (!ret) return;
  $grid.commitProxy("query");
};
